<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
		<title>项目评审修改页面</title>
		<link rel="stylesheet" href="../../css/css.css" type="text/css"></link>
		<link rel="stylesheet" href="../../css/counter.css" type="text/css"></link>
		<script src="<%=basePath%>/javascript/jquery.js"></script>
		<style type="text/css">
		#tipDiv{
		background:#FFCC33;
		width:440px;
		height:20px;
		border-width: 3px 3px;
        border-style: solid;
        border-color: #999;
        padding: 1px 0;
		}
		#outstandingWinner{
		color:#F00;
		font-size:15px;
		}
		#firstPrize{
		color:#F00;
		font-size:15px;
		}
		#secondPrize
		{
		color:#F00;
		font-size:15px;
		}
		#thirdPrize{
		color:#F00;
		font-size:15px;
		}
		 .buttonface {
	background:#999 url(../../images/21_08.gif);
	background-repeat:repeat;
	border: none;
	COLOR: #4c4c4c;
	FONT-SIZE: 12px;
	FONT-STYLE: normal;
	FONT-VARIANT: normal;
	FONT-WEIGHT: normal;
	width: 69px;
	HEIGHT: 21px;
	LINE-HEIGHT: normal;
	cursor:pointer;
   }
		</style>
		<script type="text/javascript">
		$(document).ready(function() { 
		checkNode(this);
		$("input[@type=radio]").each(function(){
		  $(this).click(function(){
           checkNode(this);
        });
		});
		});
		
		function checkNode(self){
		var outstandingWinnerCount=0;
		var firstPrizeCount=0;
		var secondPrizeCount=0;
		var thirdPrizeCount=0;
		$("input[@type=radio][@prizeType=outstandingWinner][@checked]").each(
		function(){
		outstandingWinnerCount=outstandingWinnerCount+1;
		});
		$("input[@type=radio][@prizeType=firstPrize][@checked]").each(
		function(){
		firstPrizeCount=firstPrizeCount+1;
		});
		$("input[@type=radio][@prizeType=secondPrize][@checked]").each(
		function(){
		secondPrizeCount=secondPrizeCount+1;
		});
		$("input[@type=radio][@prizeType=thirdPrize][@checked]").each(
		function(){
		thirdPrizeCount=thirdPrizeCount+1;
		});
		$("#outstandingWinner").html(outstandingWinnerCount);
		$("#firstPrize").html(firstPrizeCount);
		$("#secondPrize").html(secondPrizeCount);
		$("#thirdPrize").html(thirdPrizeCount);
		if(2<=outstandingWinnerCount)
		{
		 $("input[@type=radio][@prizeType=outstandingWinner][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","red"); 
		   });
           alert("特等奖只能评选一个，请重新选择奖项！");		
		}
		else if(2>outstandingWinnerCount)
		{
		 $("input[@type=radio][@prizeType=outstandingWinner][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","#FFFF66"); 
		   });
		}
		if(6<=firstPrizeCount)
		{
		   $("input[@type=radio][@prizeType=firstPrize][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","red"); 
		   });
               alert("一等奖只能评选5个，请重新选择奖项！");		
               
		}
		else if(6>firstPrizeCount)
		{
		  $("input[@type=radio][@prizeType=firstPrize][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","#FFFF66"); 
		   });
		}
		if(16<=secondPrizeCount)
		{
		   $("input[@type=radio][@prizeType=secondPrize][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","red"); 
		   });
               alert("二等奖只能评选15个，请重新选择奖项！");		
		}
		else if(16>secondPrizeCount)
		{
		    $("input[@type=radio][@prizeType=secondPrize][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","#FFFF66"); 
		   });
		}
		if(31<=thirdPrizeCount)
		{
		    $("input[@type=radio][@prizeType=thirdPrize][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","red"); 
		   });
               alert("三等奖只能评选30个，请重新选择奖项！");		
		}
		else if(31>thirdPrizeCount)
		{
		 $("input[@type=radio][@prizeType=thirdPrize][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","#FFFF66"); 
		   });
		}
		}
		
		
		function checkForm()
		{
		var outstandingWinnerCount=0;
		var firstPrizeCount=0;
		var secondPrizeCount=0;
		var thirdPrizeCount=0;
		$("input[@type=radio][@prizeType=outstandingWinner][@checked]").each(
		function(){
		outstandingWinnerCount=outstandingWinnerCount+1;
		});
		$("input[@type=radio][@prizeType=firstPrize][@checked]").each(
		function(){
		firstPrizeCount=firstPrizeCount+1;
		});
		$("input[@type=radio][@prizeType=secondPrize][@checked]").each(
		function(){
		secondPrizeCount=secondPrizeCount+1;
		});
		$("input[@type=radio][@prizeType=thirdPrize][@checked]").each(
		function(){
		thirdPrizeCount=thirdPrizeCount+1;
		});
		if(2<=outstandingWinnerCount)
		{
		 $("input[@type=radio][@prizeType=outstandingWinner][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","red"); 
		   });
           alert("特等奖只能评选一个，请重新选择奖项！");	
           return false;	
		}
		else if(6<=firstPrizeCount)
		{
		   $("input[@type=radio][@prizeType=firstPrize][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","red"); 
		   });
               alert("一等奖只能评选5个，请重新选择奖项！");		
               return false;
		}
		else if(16<=secondPrizeCount)
		{
		   $("input[@type=radio][@prizeType=secondPrize][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","red"); 
		   });
               alert("二等奖只能评选15个，请重新选择奖项！");		
               return false;
		}
		else if(31<=thirdPrizeCount)
		{
		    $("input[@type=radio][@prizeType=thirdPrize][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","red"); 
		   });
               alert("三等奖只能评选30个，请重新选择奖项！");		
               return false;
		}
		else{
		  if(confirm("确认投票？特等奖："+outstandingWinnerCount+"票,一等奖："+firstPrizeCount+"票，二等奖："+secondPrizeCount+"票，三等奖："+thirdPrizeCount+"票"))
		   {
		   return true;
		   }
		   else
		   {
		   return false;
		   }
		}
		}
		
		function resetRadio(self)
		{
		   
		$(self).parent("td").prev("td").children(":radio").removeAttr("checked");
		$(self).parent("td").parent("tr").attr("bgcolor","#9966FF");
		   
		var outstandingWinnerCount=0;
		var firstPrizeCount=0;
		var secondPrizeCount=0;
		var thirdPrizeCount=0;
		$("input[@type=radio][@prizeType=outstandingWinner][@checked]").each(
		function(){
		outstandingWinnerCount=outstandingWinnerCount+1;
		});
		$("input[@type=radio][@prizeType=firstPrize][@checked]").each(
		function(){
		firstPrizeCount=firstPrizeCount+1;
		});
		$("input[@type=radio][@prizeType=secondPrize][@checked]").each(
		function(){
		secondPrizeCount=secondPrizeCount+1;
		});
		$("input[@type=radio][@prizeType=thirdPrize][@checked]").each(
		function(){
		thirdPrizeCount=thirdPrizeCount+1;
		});
		$("#outstandingWinner").html(outstandingWinnerCount);
		$("#firstPrize").html(firstPrizeCount);
		$("#secondPrize").html(secondPrizeCount);
		$("#thirdPrize").html(thirdPrizeCount);
		if(2<=outstandingWinnerCount)
		{
		 $("input[@type=radio][@prizeType=outstandingWinner][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","red"); 
		   });
           alert("特等奖只能评选一个，请重新选择奖项！");		
		}
		else if(2>outstandingWinnerCount)
		{
		 $("input[@type=radio][@prizeType=outstandingWinner][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","#FFFF66"); 
		   });
		}
		if(6<=firstPrizeCount)
		{
		   $("input[@type=radio][@prizeType=firstPrize][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","red"); 
		   });
               alert("一等奖只能评选5个，请重新选择奖项！");		
               
		}
		else if(6>firstPrizeCount)
		{
		  $("input[@type=radio][@prizeType=firstPrize][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","#FFFF66"); 
		   });
		}
		if(16<=secondPrizeCount)
		{
		   $("input[@type=radio][@prizeType=secondPrize][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","red"); 
		   });
               alert("二等奖只能评选15个，请重新选择奖项！");		
		}
		else if(16>secondPrizeCount)
		{
		    $("input[@type=radio][@prizeType=secondPrize][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","#FFFF66"); 
		   });
		}
		if(31<=thirdPrizeCount)
		{
		    $("input[@type=radio][@prizeType=thirdPrize][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","red"); 
		   });
               alert("三等奖只能评选30个，请重新选择奖项！");		
		}
		else if(31>thirdPrizeCount)
		{
		 $("input[@type=radio][@prizeType=thirdPrize][@checked]").each(
		   function(){
		      $(this).parent("#vote").parent("tr").attr("bgcolor","#FFFF66"); 
		   });
		}
		}
		</script>
	</head>

	<body>
		<form name="form1" method="post"
			action="admin/review/addProjectVote.action"
			onsubmit="return checkForm()">
			<table width="100%" border="0">
				<tr>

					<td width="30%">
						<FONT class="font_lv">请对项目进行评选：</FONT>
					</td>
					<td align="left" width="50%">
						<div id="tipDiv">
							&nbsp;&nbsp;特等奖已勾选
							<span id="outstandingWinner">0</span>个，一等奖已勾选
							<span id="firstPrize">0</span>个，二等奖已勾选
							<span id="secondPrize">0</span>个，三等奖已勾选
							<span id="thirdPrize">0</span>个
							
					</td>
					<td width="20%" align="left"><input type="button" value="返回" onclick="javascript:history.go(-1);" class="buttonface" width="20px" /></td>
				</tr>
			</table>
			<table cellSpacing="1" cellPadding="1" width="100%" align="center"
				border="0">
				<tr>
					<td class=line>
						<table cellSpacing="1" cellPadding="2" width="100%" align="center"
							bgcolor="#CCCCCC" border=0>

							<tr>

								<td width="5%" height="19" align="center "
									background="../../images/manage/title_bg.jpg"
									class="font_12_B_w">
									序号
								</td>
								<td width="30%" align="center"
									background="../../images/manage/title_bg.jpg"
									class="font_12_B_w">
									项目名称
								</td>
								<td width="20%" align="center"
									background="../../images/manage/title_bg.jpg"
									class="font_12_B_w">
									专利权人
								</td>
								<td width="20%" align="center"
									background="../../images/manage/title_bg.jpg"
									class="font_12_B_w">
									建议奖级
								</td>
								<td width="15%" align="center" colspan="2"
									background="../../images/manage/title_bg.jpg"
									class="font_12_B_w">
									评选奖级
								</td>
							</tr>
							<s:iterator value="expertsReviewModel3List" status="xrr">
								<tr bgcolor="#FFFFFF">
									<td height="27" align="center">
										<s:property value="${xrr.count}" />
									</td>
									<td height="27" align="left">
										<s:property value="basicInfoModel.name" />
									</td>
									<td height="27" align="center">
										<s:property value="basicInfoModel.zlqr" />
									</td>
									<td height="27" align="center">
										<s:property value="basicInfoModel.xkmc" />组
										<br>
										建议为<s:property value="jydj.name" />
									</td>
									<td height="27" id="vote" width="8%">
										<input name="voteList[${xrr.index}].basicInfoId" type=hidden
											value="${basicInfoModel.zlid}"/ >
										<input name="voteList[${xrr.index}].jydjId" type=hidden
											value="${jydj.id}"/ >

										<s:if test="${pxjj.id eq 00}">
											<input name="voteList[${xrr.index}].pxdjId" type="radio"
												value="00" prizeType="outstandingWinner" checked="checked">
										</s:if>
										<s:else>
											<input name="voteList[${xrr.index}].pxdjId" type="radio"
												value="00" prizeType="outstandingWinner">
										</s:else>
										特等<br/>
										<s:if test="${pxjj.id eq 01}">
											<input type="radio" name="voteList[${xrr.index}].pxdjId"
												value="01" prizeType="firstPrize" checked="checked">
										</s:if>
										<s:else>
											<input type="radio" name="voteList[${xrr.index}].pxdjId"
												value="01" prizeType="firstPrize">
										</s:else>
										壹等
										<br/>
										<s:if test="${pxjj.id eq 02}">
											<input type="radio" name="voteList[${xrr.index}].pxdjId"
												value="02" prizeType="secondPrize" checked="checked">
										</s:if>
										<s:else>
											<input type="radio" name="voteList[${xrr.index}].pxdjId"
												value="02" prizeType="secondPrize">
										</s:else>
										贰等<br/>
										<s:if test="${pxjj.id eq 03}">
											<input type="radio" name="voteList[${xrr.index}].pxdjId"
												value="03" prizeType="thirdPrize" checked="checked">
										</s:if>
										<s:else>
											<input type="radio" name="voteList[${xrr.index}].pxdjId"
												value="03" prizeType="thirdPrize">
										</s:else>
										叁等
										<br/>
									</td>
									<td height="27" width="7%">
										<input type="button" value="弃权" onclick="resetRadio(this)" class="buttonface">
									</td>
								</tr>
							</s:iterator>
							<tr bgcolor="#FFFFFF">
								<td colspan="6" align="center">
									<input type="submit" value="提交" class="buttonface" width="20px" />&nbsp;&nbsp;&nbsp;
										<input type="button" value="返回" onclick="javascript:history.go(-1);" class="buttonface" width="20px" />
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</form>
	</body>
</html>
